package thread.threadlocal;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

public class ThreadLocalDemo01 {
    static SimpleDateFormat simpleDateFormat = new SimpleDateFormat("mm:ss");

    public static ExecutorService threadPool = Executors.newFixedThreadPool(2);

    public static void main(String[] args) throws InterruptedException {
        long l = System.currentTimeMillis();
        for (int i = 0; i < 10; i++) {
            int finalI = i;
            threadPool.submit(() -> {
                String data = new ThreadLocalDemo01().date(finalI);
                System.out.println(data);
            });
            Thread.sleep(10L);
        }
        threadPool.shutdown();
        long b = System.currentTimeMillis() - l;
        System.out.println(b);
    }

    private String date(int seconds){
        Date date = new Date(1000 * seconds);
        return simpleDateFormat.format(date);
    }
}